package com.gimc.evil.controller

import com.gimc.evil.service.RedisDelMatchService
import io.swagger.annotations.Api
import org.slf4j.{Logger, LoggerFactory}
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.{GetMapping, PathVariable, RequestMapping, RequestParam, RestController}

/**
 *
 * @author yin.he
 */
@Api(value = "用户相关接口")
@RestController
@RequestMapping(value = Array("redis"))
class RedisDelMatchController {

  private[this] val LOGGER: Logger = LoggerFactory.getLogger(getClass)

  @Autowired
  private val redisDelMatchService: RedisDelMatchService = null

  @GetMapping(value = Array("prefix-del"))
  def delPrefixKey(@RequestParam prefixKey: String): Boolean = {
    LOGGER.info(s"删除键：${prefixKey}")
    redisDelMatchService.delPrefixKey(prefixKey)
  }

  @GetMapping(value = Array("prefix-list"))
  def prefixList(@RequestParam prefixKey: String): Set[String] = {
    LOGGER.info(s"根据前缀获取所有的key：${prefixKey}")
    redisDelMatchService.prefixList(prefixKey)
  }

  @GetMapping(value = Array("del"))
  def delKey(@RequestParam key: String): Boolean = {
    LOGGER.info(s"删除键：${key}")
    redisDelMatchService.delKey(key)
  }
}